/**
 * Copyright (C) 2017 - 2020 https://github.com/joewee
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.model.sap;

import com.bifrost.cbentity.SapContract;
import com.bifrost.cbentity.SapContractProduct;
import com.bifrost.entity.SapStoreGoods;
import com.thoughtworks.xstream.annotations.XStreamAlias;

import java.io.Serializable;

/**
 * 销售行项目增强信息
 *
 * @author joewee
 * @version 1.0.0
 * @Date 2018/5/18 12:02
 */
@XStreamAlias("ITEM4")
public class RetailItemExtension extends BaseXml implements Serializable{
    public static final String FIELD_GROUP_RECNNR = "1007";
    public static final String FIELD_GROUP_ZZGHN = "1009";
    public static final String FIELD_GROUP_CONS_PROCG = "1012";
    public static final String FIELD_GROUP_CONS_OTRANSNUMBER = "2001";

    public static final String FIELD_NAME_RECNNR = "RECNNR";
    public static final String FIELD_NAME_ZZGHN = "ZZGHN";
    public static final String FIELD_NAME_CONS_PROCG = "CONS_PROCG";
    public static final String FIELD_NAME_CONS_OTRANSNUMBER = "OTRANSNUMBER";

    public static final String RECNNR_DATE_FOTMAT = "yyyyMMdd";



    /**
     * 销售行项目编号
     */
    @XStreamAlias("RETAILNUMBER")
    private Integer retailNumber;
    /**
     * 增强组
     */
    @XStreamAlias("FIELDGROUP")
    private String fieldGroup;
    /**
     * 字段名称
     */
    @XStreamAlias("FIELDNAME")
    private String fieldName;
    /**
     * 字段值
     */
    @XStreamAlias("FIELDVALUE")
    private String fieldValue;

    /**
     * 创建合同增强
     * @param retailNumber 销售行项目编号
     * @param protocol
     */
    public RetailItemExtension(Integer retailNumber,SapContract sapContract) {
        this.retailNumber = retailNumber;
        this.fieldGroup = FIELD_GROUP_RECNNR;
        this.fieldName = FIELD_NAME_RECNNR;
        this.fieldValue = sapContract.getRecnnr();
    }

    /**
     * 创建柜号增强
     * @param retailNumber 销售行项目编号
     * @param contractProduct
     */
    public RetailItemExtension(Integer retailNumber, SapContractProduct contractProduct) {
        this.retailNumber = retailNumber;
        this.fieldGroup = FIELD_GROUP_ZZGHN;
        this.fieldName = FIELD_NAME_ZZGHN;
        this.fieldValue = contractProduct.getZzghn();
    }

    /**
     * 创建寄售控制增强
     * @param retailNumber 销售行项目编号
     * @param storeGoods
     */
    public RetailItemExtension(Integer retailNumber, SapStoreGoods storeGoods) {
        this.retailNumber = retailNumber;
        this.fieldGroup = FIELD_GROUP_CONS_PROCG;
        this.fieldName = FIELD_NAME_CONS_PROCG;
        this.fieldValue = storeGoods.getConsProcg()==null ? "" : storeGoods.getConsProcg();
    }

    /**
     * 创建默认增强
     * @param retailNumber 销售行项目编号
     */
    public RetailItemExtension(Integer retailNumber) {
        this.retailNumber = retailNumber;
        this.fieldGroup = FIELD_GROUP_CONS_OTRANSNUMBER;
        this.fieldName = FIELD_NAME_CONS_OTRANSNUMBER;
        this.fieldValue = "0" + retailNumber;
    }

    public RetailItemExtension() {

    }

    public Integer getRetailNumber() {
        return retailNumber;
    }

    public void setRetailNumber(Integer retailNumber) {
        this.retailNumber = retailNumber;
    }

    public String getFieldGroup() {
        return fieldGroup;
    }

    public void setFieldGroup(String fieldGroup) {
        this.fieldGroup = fieldGroup;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getFieldValue() {
        return fieldValue;
    }

    public void setFieldValue(String fieldValue) {
        this.fieldValue = fieldValue;
    }
}
